package com.yzh.homework.homework02;

/**
 * @author 于振晗
 * @title: Monster
 * @description: TODO 妖怪类
 * @date 2020年08月26日
 * @path com.yzh.homework.homework
 */
public class Monster {
    private String name;
    private int hp;
    private int attack;

    public Monster() {
    }

    public Monster(String name, int hp, int attack) {
        this.name = name;
        this.hp = hp;
        this.attack = attack;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public int getAttack() {
        return attack;
    }

    public void setAttack(int attack) {
        this.attack = attack;
    }

    public void attack(){
        System.out.println("怪物"+this.name+"展开攻击");
        System.out.println("当前生命值是："+this.hp);
        System.out.println("当前攻击力是："+this.attack);
    }

    public void move(){
        System.out.println("移动中");
    }
}

class Snake extends Monster{
    public Snake(String name, int hp, int attack) {
        super(name, hp, attack);
    }

    public void blood(){
        if(getHp()<10){
            setHp(super.getHp()+20);
            System.out.println("实施大蛇补血术，当前生命值是："+getHp());
        }else{
            System.out.println("当前生命值是："+getHp());
        }

    }

    @Override
    public void move() {
        System.out.println("我是蛇怪，走S型路线");
    }
}

class Centipede extends Monster{

    public Centipede(String name, int hp, int attack) {
        super(name, hp, attack);
    }

    @Override
    public void move() {
        System.out.println("我是蜈蚣精，御风飞行");
    }
}

class Test{
    public static void main(String[] args) {
        Snake snake = new Snake("蛇怪", 5, 20);
        snake.attack();
        snake.blood();
        snake.move();
        System.out.println("===================");
        Centipede centipede = new Centipede("蜈蚣精", 60, 15);
        centipede.attack();
        centipede.move();
    }
}
